import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import store from '@/store';
import Navigation from '@/components/navigation'
import Pagination from '@/components/pagination'
import './permission'
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
Vue.use(ElementUI)

Vue.filter('dateFormat', function (val, args) {
  var time = new Date(val);
  var year = time.getFullYear();
  var month = time.getMonth() + 1;
  var day = time.getDate();

  if (month < 10) month = "0" + month;
  if (day < 10) day = "0" + day;

  if (args.toLowerCase() === "yyyy-mm-dd") {
    return year + "年" + month + "月" + day + "日";
  } else {
    var hour = time.getHours();
    var min = time.getMinutes();
    var sec = time.getSeconds();

    if (hour < 10) hour = "0" + hour;
    if (min < 10) min = "0" + min;
    if (sec < 10) sec = "0" + sec;

    return (
      year +
      "年" +
      month +
      "月" +
      day +
      "日" +
      " " +
      hour +
      ":" +
      min +
      ":" +
      sec
    );
  }
})

Vue.component(Navigation.name, Navigation)
Vue.component(Pagination.name, Pagination)
Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.dataset.title
  }
})

new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')
